package com.cfets.annualAssessment.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.util.StringUtils;

import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;

/**
 * Created by ShenYiChou on 2016/12/23.
 */
@Data
@Table(name = "t_annual_inform")
public class AnnualInform extends BaseEntity {
    private String wechat_name;
    @NotEmpty(message = "证书号不能为空")
    private String ca_num;
    @NotEmpty(message = "姓名不能为空")
    private String name;
//    @NotEmpty(message = "ID类型不能为空")
    private int id_type;
    @NotEmpty(message = "ID号不能为空")
    private String id_num;
    private int org_type;//本币交易成员1 非本币交易成员2 无机构3
    private String org_name;
//    @NotEmpty(message = "当次年检状态不能为空")
    private int annual_stat;
    private int bf_annual_stat;
//    @NotEmpty(message = "证书状态不能为空")
    private int ca_stat;
    private String qq;
    private int dept_type;
    private String dept;
    private int duty_type;
    private String duty;
    private int pos_type;
    private String deal_type;
    private String mobile;
    private String phone;
    private String cred_record;
    private String org_addr;
    private String postcode;
    private String fax;
    private String e_mail;
    private int sex;
    private String birth_date;
    private String highest_edu;
    private String degree;
    private String highest_sch;
    private String major;
    private String graduate_date;
    private String position;
    //考试机会
    @JsonIgnore
    private int chance;
    //前台页面权限(可用可不用)
    @Transient
    private int permission;

    @JsonIgnore
    @Transient
    private List<Parameter> dept_typeList;
    @JsonIgnore
    @Transient
    private List<Parameter> duty_typeList;
    @JsonIgnore
    @Transient
    private List<Parameter> pos_typeList;
//    @JsonIgnore
//    @Transient
//    private List<Parameter> deal_typeList;

    @Transient
    private List<WorkExp> workExpList;
    @Transient
    private List<AnnualHistory> annualHistoryList;
    @Transient
    private List<Honor> honorList;

    public void impSex(String sex){
        switch (sex){
            case "男":this.sex = 1;break;
            case "女":this.sex = 2;break;
            default:break;
        }
    }

    public void impId_type(String id_type){
        switch (id_type){
            case "身份证":this.id_type = 1 ;break;
            case "护照":this.id_type = 2 ;break;
            case "港澳台证件":this.id_type = 3;break;
            case "其他":this.id_type = 4 ;break;
            default:break;
        };
    }

    public void impOrg_type(String org_type){
        switch (org_type){
            case "本币交易成员":this.org_type = 1 ;break;
            case "非本币交易成员":this.org_type = 2 ;break;
            case "无机构":this.org_type = 3;break;
            default:break;
        };
    }

    public void impAnnual_stat(String annual_stat){
        switch (annual_stat){
            case "未年检":this.annual_stat = 1 ;break;
            case "待审核":this.annual_stat = 2 ;break;
            case "通过":this.annual_stat = 3;break;
            case "不通过":this.annual_stat = 4 ;break;
            default:break;
        };
    }

    public void impBf_annual_stat(String bf_annual_stat){
        switch (bf_annual_stat){
            case "未年检":this.bf_annual_stat = 1 ;break;
            case "待审核":this.bf_annual_stat = 2 ;break;
            case "通过":this.bf_annual_stat = 3;break;
            case "不通过":this.bf_annual_stat = 4 ;break;
            default:break;
        };
    }

    public void impCa_stat(String ca_stat){
        switch (ca_stat){
            case "有效":this.ca_stat = 1 ;break;
            case "暂停":this.ca_stat = 2 ;break;
            case "注销":this.ca_stat = 3;break;
            default:break;
        };
    }

    public void impDept_type(String dept_type){
        for(Parameter item:this.dept_typeList){
            if(dept_type.equals(item.getPara_value())) this.dept_type = item.getPara_order();
        }
    }
    public void impDuty_type(String duty_type){
        for(Parameter item:this.duty_typeList){
            if(duty_type.equals(item.getPara_value())) this.duty_type = item.getPara_order();
        }
    }
    public void impPos_type(String pos_type){
        for(Parameter item:this.pos_typeList){
            if(pos_type.equals(item.getPara_value())) this.pos_type = item.getPara_order();
        }
    }
}
